package person.wend.pluginm;


/**
 * 使用插件的消费者
 */
public class PluginProvider {

    public AbstractJobPlugin getUsePlugin(String pluginName) {
        LoadUtil loadUtil = new LoadUtil(pluginName);
        // 寻找插件Jar包集合
        JarLoader jarLoader = loadUtil.getJarLoader();
        try {
            Class<? extends AbstractJobPlugin> clazz =
                    (Class<? extends AbstractJobPlugin>) jarLoader
                            .loadClass(loadUtil.getClassName()); // person.wend.plugin1.provider.Plugin1Provider
            AbstractJobPlugin job = clazz.newInstance();
            return job;
        } catch (Exception e) {
            throw new RuntimeException("加载插件失败", e);
        }
    }


}
